class GoodsDataList {
  List<GoodsData> list;

  GoodsDataList({this.list});

  GoodsDataList.fromJson(List json) {
    if (json != null) {
      list = <GoodsData>[];
      json.forEach((v) {
        list.add(GoodsData.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.list != null) {
      data['list'] = this.list.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class GoodsData {
  String id;
  String goodsName;
  String production;
  String brand;
  String logo;
  List<String> activities;
  List<String> mainPics;
  List<String> comments;
  String detail;
  String price;
  int soldNum;
  int commentsNum;
  List<Specs> specs;
  int totalStock;

  GoodsData(
      {this.id,
      this.goodsName,
      this.production,
      this.brand,
      this.logo,
      this.activities,
      this.mainPics,
      this.comments,
      this.detail,
      this.price,
      this.soldNum,
      this.commentsNum,
      this.specs,
      this.totalStock});

  GoodsData.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    goodsName = json['goodsName'];
    production = json['production'];
    brand = json['brand'];
    logo = json['logo'];
    activities = json['activities'].cast<String>();
    mainPics = json['mainPics'].cast<String>();
    comments = json['comments'].cast<String>();
    detail = json['detail'];
    price = json['price'];
    soldNum = json['soldNum'];
    commentsNum = json['commentsNum'];
    if (json['specs'] != null) {
      specs = <Specs>[];
      json['specs'].forEach((v) {
        specs.add(Specs.fromJson(v));
      });
    }
    totalStock = json['totalStock'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['goodsName'] = this.goodsName;
    data['production'] = this.production;
    data['brand'] = this.brand;
    data['logo'] = this.logo;
    data['activities'] = this.activities;
    data['mainPics'] = this.mainPics;
    data['comments'] = this.comments;
    data['detail'] = this.detail;
    data['price'] = this.price;
    data['soldNum'] = this.soldNum;
    data['commentsNum'] = this.commentsNum;
    if (this.specs != null) {
      data['specs'] = this.specs.map((v) => v.toJson()).toList();
    }
    data['totalStock'] = this.totalStock;
    return data;
  }
}

class Specs {
  int goodsPrice;
  int goodsStock;
  String goodsSpec;
  String specImg;
  String specId;

  Specs(
      {this.goodsPrice,
      this.goodsStock,
      this.goodsSpec,
      this.specImg,
      this.specId});

  Specs.fromJson(Map<String, dynamic> json) {
    goodsPrice = json['goodsPrice'];
    goodsStock = json['goodsStock'];
    goodsSpec = json['goodsSpec'];
    specImg = json['specImg'];
    specId = json['specId'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['goodsPrice'] = this.goodsPrice;
    data['goodsStock'] = this.goodsStock;
    data['goodsSpec'] = this.goodsSpec;
    data['specImg'] = this.specImg;
    data['specId'] = this.specId;
    return data;
  }
}
